package com.estore.service;

import com.estore.model.Product;

import java.util.Comparator;

public class ProductSorters {
    //从价格升序排序
    public static final Comparator<Product> BY_PRICE_ASC = Comparator.comparingDouble(Product::getPrice);
    //从价格降序排序
    public static final Comparator<Product> BY_PRICE_DESC = BY_PRICE_ASC.reversed();
    //从库存数量降序排序
    public static final Comparator<Product> BY_STOCK_DESC = Comparator.comparingInt(Product::getStock).reversed();
}
